package eight.abstractfactory.example;

import eight.abstractfactory.example.factory.Factory;
import eight.abstractfactory.example.factory.Link;
import eight.abstractfactory.example.factory.Page;
import eight.abstractfactory.example.factory.Tray;

public class Main {
    public static void main(String[] args) {
        if(args.length !=1){
            System.out.println("Usage:java Main class.name.of.ConcreteFactory");
            System.out.println("Example 1: java Main listfactory.ListFactory");
            System.out.println("Example 2: java Main tablefactory.TableFactory");
        }
        Factory factory = Factory.getFactory(args[0]);

        Link people = factory.createLink("人民日报","http://www.people.com.cn");
        Link gmw = factory.createLink("光明日报","http://www.gmw.cn");

        Link sogou = factory.createLink("搜狗","http://www.sogou.com");
        Link baidu = factory.createLink("百度","http://www.baidu.com");

        Tray traynews = factory.createTray("日报");
        traynews.add(people);
        traynews.add(gmw);

        Tray traysearch = factory.createTray("搜索引擎");
        traysearch.add(sogou);
        traysearch.add(baidu);

        Page page = factory.createPage("LinkPage","栋");
        page.add(traynews);
        page.add(traysearch);
        page.output();

    }
}
